# -*- shell-script -*-

# 40ibm,vpd - lsvpd-specific functions for systems with ibm,vpd properties.

# This file is part of the Linux lsvpd package.

# (C) Copyright IBM Corp. 2002, 2003, 2004, 2005

# Maintained by Martin Schwenke <martins@au.ibm.com>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    
# $Id: 40ibm,vpd,v 1.1 2006/04/11 18:38:28 emunson Exp $

[ "$device_tree_device_type" = "chrp" ] || return 0

######################################################################

case "$LSVPD_LIST_BUILTIN" in
    (true|false) :                           ;;
    (*)          LSVPD_LIST_BUILTIN=false ;;
esac

should_render ()
{
    local dir="$1"
    local ds="$2"
    local ax="$3"
    local yl="$4"

    should_render_basic "$dir" "$ds" "$ax" "$yl" || return 1  ### !!!

    local bd="${dir##*/}" # basename

    # Don't list items if they are built-in, they are missing the
    # ibm,vpd property and YL ends with "P1".
    if ! $LSVPD_LIST_BUILTIN ; then
	[ -f "${dir}/built-in" -a \
	    ! -f "${dir}/ibm,vpd" -a \
	    "${yl##*-}" = "P1" ] && \
	    return 1
    fi

    # Don't list PCI buses.
    case "$bd" in
	(pci@*|isa@*) return 1 ;;
    esac

    # Don't list virtuals.
    case "$dir" in
	(*/vdevice/*) return 1 ;;
    esac

    return 0
}
